$(function(){

	/*高端理财-手机客户端*/
	$(".phone_sm").mouseenter(function(){
		$(".phone_rwm").show();
	});
	$(".phone_sm").mouseleave(function(){
		$(".phone_rwm").hide();
	});
	/*高端理财-官方微信*/
	$(".wx_sm").mouseenter(function(){
		$(".weinxi_rwm").show();
	});
	$(".wx_sm").mouseleave(function(){
		$(".weinxi_rwm").hide();
	});

	//基金赛选
	$(".index_fundtb th").click(function(){
		$(this).children("span").addClass("down");
	    $(this).siblings().children("span").removeClass("down");
	    
	});
	
	$(".index_fund_list li").mouseenter(function(){
    $(".index_fund_list li").eq($(this).index()).addClass("active").siblings().removeClass('active');
	$(".fund_list_item").hide().eq($(this).index()).show(); });

	 //净值估算 tab
	$("#secondMenu li").mouseenter(function(){
    $("#secondMenu li").eq($(this).index()).addClass("active").siblings().removeClass('active');
	$(".jz_item").hide().eq($(this).index()).show(); });
	
	
	/*订阅号扫描*/
	$(".subscribe_h").mouseenter(function(){
		$(".subscribe_sm").show();
	});
	$(".subscribe_h").mouseleave(function(){
		$(".subscribe_sm").hide();
	});

	$(".service_h").mouseenter(function(){
		$(".service_sm").show();
	});
	$(".service_h").mouseleave(function(){
		$(".service_sm").hide();
	});
	$(".ser_APP").mouseenter(function(){
		$(".service_APP").show();
	});
	$(".ser_APP").mouseleave(function(){
		$(".service_APP").hide();
	});

	/*导航栏下拉*/
	$("#nav ul li").mouseenter(function(){
		$(this).children(".Drop_down").show();
	});
	$("#nav ul li").mouseleave(function(){
		$(this).children(".Drop_down").hide();
	});
	$("#nav ul li").mouseenter(function(){
		$(this).children(".Drop_down_sp").show();
	});
	$("#nav ul li").mouseleave(function(){
		$(this).children(".Drop_down_sp").hide();
	});

	/*基金超市选项卡*/
	$(".breadcrumb ul li").mouseenter(function(){
		$(this).children(".fund_Drop_down").show();
	});
	$(".breadcrumb ul li").mouseleave(function(){
		$(this).children(".fund_Drop_down").hide();
	});

	$(".breadcrumb ul li").mouseenter(function(){
		$(this).children(".fund_Drop_down_spa").show();
	});
	$(".breadcrumb ul li").mouseleave(function(){
		$(this).children(".fund_Drop_down_spa").hide();
	});
	
	/*qysyb banner*/
/*	$('.flexslider').flexslider({
			directionNav: true,
			pauseOnAction: false
		});
		*/
	$(".zilaio").mouseenter(function(){
			$(this).children(".zilaio_hover").show();
		});
		$(".zilaio").mouseleave(function(){
			$(this).children(".zilaio_hover").hide();
		});
		
	//超级现金宝 问答 tab
	$("#cjwtbox .dao:eq(0)").show();
	$("#cjwtbox .cjwtbox_q").click(function(){
	$(this).addClass("cjwtbox_current").next(".dao").slideDown(500).siblings(".dao").slideUp("slow");
	$(this).siblings().removeClass("cjwtbox_current");
});

});



/*首页滚动条监听*/
$(function(){
	if($("#fund_market").length == 0) {
		return;
	}

	var isIE7 = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/7./i)=="7.");
	function scrollEvent() {
		var a = $(window).scrollTop()+$(window).height();
		b = $("#fund_market").next().position().top-$("#fund_market").height();
		if(a>b){
			$("#fund_market").removeClass(isIE7 ? "fund_market_fixed7" : "fund_market_fixed");
		}
		else {
			$("#fund_market").addClass(isIE7 ? "fund_market_fixed7" : "fund_market_fixed");
		}
	}

	$(window).scroll(scrollEvent);
	scrollEvent();

	//////////////////////////////////////////////////////////////  -$("#fund_market").height()
	$("#fund_market li a").click(function() {
		$('html,body').animate({scrollTop:$("#fund_market").position().top}, 800);
	});
});

// 热门基金表头基金名称宽度
function adjustHeaderWidth(index) {
	var cnt = $('.ptall15').eq(index);0
	if(cnt != null && typeof(cnt) != "undefined") {
		cnt.find('.fund_market_table').each(function(){
			var list = $(this).find('.fund_market_table_middle');
			var max = 0;
			list.each(function(){
				if($(this).width() > max){
					max = $(this).width();
				}
			});
			list.css('width',max);
			$(this).find(".name").css('width', max+31);
		});
	}
}

//////////////////////////////////////////////////////////////////
// 首页推荐基金
function getStyle(obj,name)
{
	if(obj.currentStyle)
	{
		return obj.currentStyle[name]
	}
	else
	{
		return getComputedStyle(obj,false)[name]
	}
}

function getByClass(oParent,nClass)
{
	var eLe = oParent.getElementsByTagName('*');
	var aRrent  = [];
	for(var i=0; i<eLe.length; i++)
	{
		if(eLe[i].className == nClass)
		{
			aRrent.push(eLe[i]);
		}
	}
	return aRrent;
}

function startMove(obj,att,add)
{
	clearInterval(obj.timer)
	obj.timer = setInterval(function(){
	   var cutt = 0 ;
	   if(att=='opacity')
	   {
		   cutt = Math.round(parseFloat(getStyle(obj,att)));
	   }
	   else
	   {
		   cutt = Math.round(parseInt(getStyle(obj,att)));
	   }

	   var speed = (add-cutt)/4;
	   speed = speed>0?Math.ceil(speed):Math.floor(speed);
	   if(cutt == add)
	   {
		   clearInterval(obj.timer)
	   }
	   else
	   {
		   if(att=='opacity')
		   {
			   obj.style.opacity = (cutt+speed)/100;
			   obj.style.filter = 'alpha(opacity:'+(cutt+speed)+')';
		   }
		   else
		   {
			   obj.style[att] = cutt+speed+'px';
		   }
	   }
	}, 30);
}

var g_moveTime = 8000;
var g_timer = null;
window.onload = function() {
	var oDiv = document.getElementById('playBox');
	if(oDiv == null) {
		return;
	}

	var oPre = getByClass(oDiv,'pre')[0];
	var oNext = getByClass(oDiv,'next')[0];
	var oUlBig = getByClass(oDiv,'oUlplay')[0];
	var aBigLi = oUlBig.getElementsByTagName('li');
	$(oPre).addClass('disable');

	function tab() {
		startMove(oUlBig,'left',-(now*aBigLi[0].offsetWidth));
		if(now === 0){
			$(oPre).addClass('disable');
		}else{
			$(oPre).removeClass('disable');
		}

		if(now == aBigLi.length - 1){
			$(oNext).addClass('disable');
		}else{
			$(oNext).removeClass('disable');
		}
	}

	function move(direct) {
		if(direct == -1) {
			now--;
			if(now == -1) {
				now = aBigLi.length-1;
			}
		}
		else {
			now++;
			if(now == aBigLi.length) {
				now = 0;
			}
		}
		tab();
	}

	g_timer = setInterval(function() {move(1)}, g_moveTime); //滚动间隔时间设置
	var now = 0;

	oPre.onclick = function() {
		if($(oPre).hasClass("disable")) {
			return;
		}
		clearInterval(g_timer);
		move(-1);
		g_timer = setInterval(function() {move(1)}, g_moveTime);
	};

	oNext.onclick = function() {
		if($(oNext).hasClass("disable")) {
			return;
		}
		clearInterval(g_timer);
		move(1);
		g_timer = setInterval(function() {move(1)}, g_moveTime);
	};

	oDiv.onmouseover = function() {
		clearInterval(g_timer);
		g_timer = null;
	};
	oDiv.onmouseout = function() {
		if(g_timer == null) {
			g_timer = setInterval(function() {move(1)}, g_moveTime); //滚动间隔时间设置
		}
	};
};

$(function(){
	$("[name='loadAttach']").each(function(){
		$(this).bind("click", function() {
			switch($(this).attr("type")){
			    //高端理财
			    case "product":
			    	$.PostPage("/new/vip/?type=product", {}, false);
				    break;
			    case "service":
			    	$.PostPage("/new/vip/?type=service", {}, false);
				    break;
			    case "inter":
			    	$.PostPage("/new/vip/?type=inter", {}, false);
				    break;
				//机构理财
			    case "gtczjy":
			    	$.PostPage("/new/agency/?type=businessGuide",{},false);
			    	break;
			    case "businessGuide":
			    	$.PostPage("/new/agency/?type=businessGuide",{},false);
			    	break;
			    case "download":
			    	$.PostPage("/new/agency/?type=download",{},false);
			    	break;
			    case "wsjy":
			    	$.PostPage("/new/agency/?type=wsjy",{},false);
			    	break;
			    //养老基金
			    case "nfnj":
			    	$.PostPage("/new/pension/?type=nfnj", {}, false);
			        break;
		        case "cpsj":
		        	$.PostPage("/new/pension/?type=cpsj", {}, false);
			        break;
		        case "njfw":
		        	$.PostPage("/new/pension/?type=njfw", {}, false);
			        break;
		        case "wmkh":
		        	$.PostPage("/new/pension/?type=wmkh", {}, false);
			        break;
		        case "njdt":
		        	$.PostPage("/new/pension/?type=njdt", {}, false);
			        break;
		        case "xxpl":
		        	$.PostPage("/new/pension/?type=xxpl", {}, false);
			        break;
		        case "ylcp":
		        	$.PostPage("/new/pension/?type=ylcp", {}, false);
			        break;
			   //客户服务
			   case "fwjs":
				   $.PostPage("/new/cs/?type=fwjs", {}, false);
				    break;
			    case "jyzn":
			    	$.PostPage("/new/cs/?type=jyzn", {}, false);
				    break;
			    case "zxwht":
			    	$.PostPage("/new/cs/?type=zxwht", {}, false);
				    break;
			    /*case "jgfw":
			    	$.PostPage("/new/cs/?type=jgfw", {}, false);
				    break;*/
			    case "tsjy":
			    	$.PostPage("/new/cs/?type=tsjy", {}, false);
				    break;
				//关于南方
				case "gsjj":
					$.PostPage("/new/aboutnf/?type=gsjj", {}, false);
				    break;
		        case "nfry":
		        	$.PostPage("/new/aboutnf/?type=nfry", {}, false);
				    break;
			    case "nfdt":
			    	$.PostPage("/new/aboutnf/?type=nfdt", {}, false);
				    break;
			    case "nfgg":
			    	$.PostPage("/new/aboutnf/?type=nfgg", {}, false);
				    break;
			    case "tysd":
			    	$.PostPage("/new/aboutnf/?type=tysd", {}, false);
				    break;
			    case "shzr":
			    	$.PostPage("/new/aboutnf/?type=shzr", {}, false);
				    break;
			    case "lxwm":
			    	$.PostPage("/new/aboutnf/?type=lxwm", {}, false);
				    break;
				default:
				    break;
			}
		});
	});
});

/*轮播图片*/
function banner(){
	var bn_id = 0;
	var bn_id2= 1;
	var speed33=5000;
	var qhjg = 1;
	var MyMar33;
	$("#banner .d1").hide();
	$("#banner .d1").eq(0).fadeIn("slow");
	if($("#banner .d1").length>1)
	{
		$("#banner_id li").eq(0).addClass("nuw");
		function Marquee33(){
			bn_id2 = bn_id+1;
			if(bn_id2>$("#banner .d1").length-1)
			{
				bn_id2 = 0;
			}
			$("#banner .d1").eq(bn_id).css("z-index","2");
			$("#banner .d1").eq(bn_id2).css("z-index","1");
			$("#banner .d1").eq(bn_id2).show();
			$("#banner .d1").eq(bn_id).fadeOut("slow");
			$("#banner_id li").removeClass("nuw");
			$("#banner_id li").eq(bn_id2).addClass("nuw");
			bn_id=bn_id2;
		};

		MyMar33=setInterval(Marquee33,speed33);

		$("#banner_id li").click(function(){
			var bn_id3 = $("#banner_id li").index(this);
			if(bn_id3!=bn_id&&qhjg==1)
			{
				qhjg = 0;
				$("#banner .d1").eq(bn_id).css("z-index","2");
				$("#banner .d1").eq(bn_id3).css("z-index","1");
				$("#banner .d1").eq(bn_id3).show();
				$("#banner .d1").eq(bn_id).fadeOut("slow",function(){qhjg = 1;});
				$("#banner_id li").removeClass("nuw");
				$("#banner_id li").eq(bn_id3).addClass("nuw");
				bn_id=bn_id3;
			}
		})
		$("#banner_id").hover(
			function(){
				clearInterval(MyMar33);
			}
			,
			function(){
				MyMar33=setInterval(Marquee33,speed33);
			}
		)
	}
	else
	{
		$("#banner_id").hide();
	}
}


